extend ./layout/default

block link
  link(rel="stylesheet", href="/static/css/editor.min.css")
  
block main-content
  #datasetForm
    if dataset
      input.hidden#PutDatasetid(value="#{dataset._id}")
      input#PostTitle(type="text"  value="#{dataset.title}")
      input#PostUrl(type="text" placeholder="dataset path" value="#{dataset.url}") 
      input#PostDescription(type="text" value="#{dataset.description}")  
      select
        option office
        option hotel
        option canteen
        option highway
        option beach
        option stadium
        option rail
      select
        option all
        option(value="jan") january
        option(value="feb") february
        option(value="mar") march
        option(value="apr") april
        option(value="may") may
        option(value="june") june
        option(value="july") july
        option(value="aug") august
        option(value="sep") september
        option(value="oct") october
        option(value="nov") november
        option(value="dec") december
      select
        option(value="3.5GHz") 3.5GHz
        option(value="millimeter") millimeter wave
        option(value="highfreq") High frequency
      select   
        option all
        option 1
        option 2
        option 3
        option 4
        option 5
        option 6
        option 7
        option 8
      |    receiver antenna
      select   
        option all
        option 1
        option 2
        option 3
        option 4
        option 5
        option 6
        option 7
        option 8
      
      #editormd
        textarea#PostContent(style="display:none;") #{dataset.content}
      input.centerbtn(type="submit" onclick="saveNewPost('PUT')" value="保存")
    else
      input#PostTitle(type="text" placeholder="dataset title" ) 
      input#PostUrl(type="text" placeholder="dataset path" ) 
      input#PostDescription(type="text" placeholder="dataset description" ) 
      span sence
      select
        option office
        option hotel
        option canteen
        option highway
        option beach
        option stadium
        option rail
      span month
      select
        option january
        option february
        option march
        option april
        option may
        option june
        option july
        option august
        option september
        option october
        option november
        option december
      span frequency
      select
        option(value="3.5GHz") 3.5GHz
        option(value="millimeter") millimeter wave
        option(value="highfreq") High frequency
      span number of sender antenna
      select   
        option 1
        option 2
        option 3
        option 4
        option 5
        option 6
        option 7
        option 8
      span number of receiver antenna
      select   
        option 1
        option 2
        option 3
        option 4
        option 5
        option 6
        option 7
        option 8
      #editormd
        textarea#PostContent(style="display:none;") ### 请使用markdown格式编辑，此处写上关于数据集的描述。
      input.centerbtn(type="submit" onclick="saveNewPost('POST')" value="保存")
    
  script(src="/static/js/editormd.min.js")
  script.
    $(function(){
      var editor = editormd('editormd',{
        height: 640,
        syncScrolling: 'single',
        width: "90%",
        path: "/static/lib/"
      });
      editor.hideToolbar()
    });
    
    var saveNewPost = function(s){
      var selects = $('select')
      $.ajax({
        url: '/dataset',
        data: {
          title: $('#PostTitle').val(),
          url: $('#PostUrl').val(),
          description: $('#PostDescription').val(),
          content: $('#PostContent').val(),
          dsid: $('#PutDatasetid').val() || null,
          scene: selects[0].value,
          month: selects[1].value,
          freq: selects[2].value,
          sendnum: selects[3].value,
          recnum: selects[4].value,
        },
        method: s,
        success: function(data){
          window.location.href = "/"
        }
      })
      
    }
    
    
    
  
